#include<iostream>
#include<regex>
#include<string>
using namespace std;

int main()
{
	cout << "Please enter a word:" << endl;
	string str = "([a-zA-Z]*[^c]ie[a-zA-Z]*)|([a-zA-Z]*cei[a-zA-Z]*)";
	regex reg(str);
	smatch results;
	bool res;
	while (getline(cin,str))
	{
		if (str == "q")
		{
			break;
		}
		res = regex_match(str, results, reg);
		if (res)
		{
			cout << results.str() << endl;
		}
		else
		{
			cout << "No match!" << endl;
		}
		cout << "The next word:" << endl;
	}
	return 0;
}